Source Code Viewer - Example 3 - FindCountryByFirstCharForm

package name.matthewgreet.example3.form;

import com.opensymphony.xwork2.TextProvider;
import com.opensymphony.xwork2.interceptor.ValidationAware;

import name.matthewgreet.example3.common.AbstractForm;


public class FindCountryByFirstCharForm extends AbstractForm {
	private static final long serialVersionUID = 8934318962457841363L;
	
	private String firstChar;
	
	private char parsedFirstChar;
	
	public FindCountryByFirstCharForm() {
		super();
		this.firstChar = "A";
	}

	public FindCountryByFirstCharForm(char firstChar) {
		super();
		this.firstChar = String.valueOf(firstChar);
	}

	@Override
	protected void resetFields() {
		firstChar = "";
	}

	@Override
	public void doValidate(ValidationAware validationAware, TextProvider textProvider) {
		if (firstChar.length() > 0) {
			parsedFirstChar = firstChar.charAt(0);
		} else {
			parsedFirstChar = 0;
		}
	}

	
	public String getFirstChar() {
		return firstChar;
	}
	public void setFirstChar(String firstChar) {
		this.firstChar = firstChar;
	}

	public char getParsedFirstChar() {
		return parsedFirstChar;
	}

	
	@Override
	public String toString() {
		return "FindCountryByFirstCharForm [firstChar=" + firstChar + "]";
	}

}